<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vuex</title>
</head>
<a href=""></a>
<body>
<!-- 
    store.js
        const vuex = new Vuex.Store({
            state: {
                userInfo: {
                    username: '',
                    userid: ''
                }
            },
            mutations: {
                setUser(state, data){
                    state.userInfo.userid = data.id
                }
            },
            actions:{
                setUser(context, data){
                    context.commit('setUser', data)
                }
            }
        })
        export default vuex
    vue组件
        methods: {
            setUser(){
                //触发action
                this.$store.dispatch('setUser', {
                    id: '6'
                });
            }
        }
    组件调用 mustations
        commit()
    组件调用 actions
        dispatch()
        
 -->
</body>
</html>